package com.test;

import java.util.ArrayList;
import java.util.Base64;

public class Base64Demo {
    public static void main(String[] args) {
        String s = Base64.getEncoder().encodeToString("谢雅婷".getBytes());
        System.out.println("s = " + s);
        byte[] decode = Base64.getDecoder().decode(s);
        System.out.println("new String(decode) = " + new String(decode));
        //url
        String s1 = Base64.getUrlEncoder().encodeToString("?loginName=admin&password=123".getBytes());
        System.out.println("s1 = " + s1);
        byte[] decode1 = Base64.getUrlDecoder().decode(s1);
        System.out.println("new String(decode1) = " + new String(decode1));
    }
}
